<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/files/admin/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="/files/admin/css/houtai.css"/>
    <title>新闻管理</title>
  <style media="screen">
  /*修改弹窗样式*/
  a,a:hover{ text-decoration:none; color:#333}
  .shadow {position:fixed; width:100%; height:100%; background:#000; opacity:0.3; filter:alpha(opacity:30);left:0; top: 0;}
  .modal-dialog{position:fixed; left:40%; top:0; z-index: 999;}
  </style>
  </head>
  <body>
  <div class="page">
    <% include components/top.inc.ejs %>
    <div class="container">
    <div class="row">
        <div class="col-md-2">
        <a href="#" class="btn btn-info" data-toggle="modal" data-target="#add"><span class="glyphicon glyphicon-plus"></span>添加</a>
        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h1>新闻管理</h1>
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>标题</th>
                        <th>新闻简介</th>
                        <th>浏览次数</th>
                        <th>图片</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                  <% for(var i=0;i<news.length;i++){ %>
                    <tr>
                      <th scope="row"><%=news[i].ID%></th>
                      <td><%=news[i].title%></td>
                      <td><%=news[i].summary%></td>
                      <td><%=news[i].view%></td>
                      <td><img width="32" height="32" src="/upload/<%=news[i].src%>"/></td>
                      <td>
                          <div role="presentation" class="dropdown">
                              <button class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">
                                  操作<span class="caret"></span>
                              </button>
                              <ul class="dropdown-menu">
                                 <li ><a href="?act=mod&id=<%=news[i].ID%>">修改</a></li>
                                 <li><a href="?act=del&id=<%=news[i].ID%>" onclick="return confirm('你真的要删吗？')">删除</a></li>
                              </ul>
                          </div>
                      </td>
                    </tr>
                    <% } %>
                </tbody>
            </table>
             <!-- 2.修改模态框 -->
            <% if(typeof mod_data!='undefined'){ %>
                <div class="shadow"></div>
                <div class="modal-dialog" style="background-color: #e5eecc; padding:10px 8px 20px 8px;">
                    <form action="?" method="post" enctype="multipart/form-data">
                      <input type="hidden" name="mod_id" value="<%= mod_data.ID %>" />
                      <div class="form-group">
                        <label for="recipient-name" class="control-label">标题:</label>
                        <input type="text" class="form-control" name="title" value="<%= mod_data.title %>">
                      </div>
                      <div class="form-group">
                        <label for="recipient-name" class="control-label">关键词:</label>
                        <input type="text" class="form-control" name="keyword" value="<%= mod_data.keyword %>">
                      </div>
                      <div class="form-group">
                        <label for="recipient-name" class="control-label">浏览次数:</label>
                        <input type="text" class="form-control" name="view" value="<%= mod_data.view %>">
                      </div>
                      <div class="form-group">
                        <label for="recipient-name" class="control-label">添加时间:</label>
                        <input type="text" class="form-control" name="post_time" value="<%= mod_data.post_time %>">
                      </div>
                      <div class="form-group">
                        <label for="text" class="control-label">描述:</label>
                        <textarea class="form-control" name="summary" rows="1"><%= mod_data.summary %></textarea>
                      </div>
                      <div class="form-group">
                        <label for="text" class="control-label">新闻内容:</label>
                        <textarea class="form-control" name="content" rows="1"><%= mod_data.content %></textarea>
                      </div>
                      <div class="form-group">
                        <label for="exampleInputFile">File input</label>
                        <input type="file" name="f1">
                      </div>
                      <a type="button" class="btn btn-info" href="/admin/news">取消</a>
                      <input type="submit" class="btn btn-danger" value="修改">
                    </form>
                </div>
                <% } %>

            
            <nav class="pull-right" class="navbar-fixed-bottom">
                <ul class="pagination">
                    <li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a></li>
                    <li class="active"><a href="#">1</a></li>
                    <li><a href="#">2 </a></li>
                    <li><a href="#">3 </a></li>
                    <li><a href="#">4 </a></li>
                    <li><a href="#">5 </a></li>
                    <li><a href="#">6 </a></li>
                    <li><a href="#"><span aria-hidden="true">&raquo;</span></a></li>
                </ul>
            </nav>
        </div>
    </div>
</div>
<!-- 1.添加模态框 -->
<div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="exampleModalLabel">添加模态框</h4>
      </div>
      <div class="modal-body">
        <form action="?" method="post" enctype="multipart/form-data">
          <div class="form-group">
            <label for="recipient-name" class="control-label">标题:</label>
            <input type="text" class="form-control" name="title">
          </div>
          <div class="form-group">
            <label for="recipient-name" class="control-label">关键词:</label>
            <input type="text" class="form-control" name="keyword">
          </div>
          <div class="form-group">
            <label for="recipient-name" class="control-label">浏览次数:</label>
            <input type="text" class="form-control" name="view">
          </div>
          <div class="form-group">
            <label for="recipient-name" class="control-label">添加时间:</label>
            <input type="text" class="form-control" name="post_time">
          </div>
          <div class="form-group">
            <label for="text" class="control-label">描述:</label>
            <textarea class="form-control" name="summary" rows="1"></textarea>
          </div>
          <div class="form-group">
            <label for="text" class="control-label">新闻内容:</label>
            <textarea class="form-control" name="content" rows="1"></textarea>
          </div>
          <div class="form-group">
            <label for="exampleInputFile">新闻缩略图</label>
            <input type="file" name="f1">
            <p class="help-block">记得上传炫酷的图片喔！</p>
          </div>
          
          <button type="button" class="btn btn-warning " data-dismiss="modal">取消</button>
          <input type="submit" class="btn btn-success" value="添加">
        </form>
      </div>
    </div>
  </div>
</div>
<script >
  $('#add').modal(options)
})
</script>
</div>
<% include components/bottom.ejs %>
</body>
<script src="/files/admin/js/jquery.min.js"></script>
<script src="/files/admin/js/bootstrap.min.js"></script>
</html>
